package com.pic.mgt.initials;

import com.pic.mgt.log.IgxLog;
import com.pic.mgt.manager.business.BusinessManagementOperationException;
import com.pic.mgt.manager.business.BusinessManager;

public final class BusinessSynchronizeInitialBean implements InitialBean {
	private BusinessManager businessManager;

	@Override
	public void initialize() throws InitialOperationException {
		try {
			businessManager.synchronizeBusiness();
		} catch (BusinessManagementOperationException e) {
			try {
				throw new InitialOperationException(
						"SUDA-252 Initializing failed: synchronizing business failed." ,e);
			} catch (InitialOperationException e1) {
				// ********************** Log **********************
				IgxLog.messageLog.error(this, e1.getMessage());
				// ********************** Log **********************
				
				throw e1;
			}
		}
		
		// ********************** Log **********************
		if (IgxLog.messageLog.isDebugMode()) {
			IgxLog.messageLog.debug(this,
					"Initializing business synchronization completed.");
		}
		// ********************** Log **********************
	}
	
	// --- getter and setter ---

	public void setBusinessManager(BusinessManager businessManager) {
		this.businessManager = businessManager;
	}

}
